<template>
    <div>
        <el-form>
            <el-form-item label="数字：">
                <el-input v-model="number" style="width:200px;" @input="() => { this.result = this.number}"></el-input>
            </el-form-item>
            <el-form-item label="小数点：">
                <el-button type="primary" @click="moveLeft">左移</el-button>
                <el-button type="primary" @click="moveRight">右移</el-button>
                <el-button type="primary" @click="() => { this.result = this.number}">还原</el-button>
            </el-form-item>
            <el-form-item label="结果：">
                <span style="font-size:40px;">
                    {{result ? result : '无'}}
                </span>
            </el-form-item>

        </el-form>
    </div>
</template>

<script>
    export default {
        name: "decimal1",
        data() {
          return {
              number: 3.14,
              result: 0,
          }
        },
        methods: {
            moveLeft() {
                this.result /= 10
                this.result = Math.round(this.result * 1000000000) / 1000000000
            },
            moveRight() {
                this.result *= 10
                this.result = Math.round(this.result * 100) / 100
            }
        },
        mounted() {
            this.result = this.number
        }
    }
</script>

<style scoped>

</style>
